package com.iflytek.universitymanagement.controller;

import com.iflytek.universitymanagement.domain.TopicSelect;
import com.iflytek.universitymanagement.service.TopicSelectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/topicSelect")
public class TopicSelectController {
    @Autowired
    private TopicSelectService topicSelectService;

    @GetMapping("/options/{tid}")
    public ResponseEntity<Map<String, Object>> getOptionsByTid(@PathVariable Integer tid) {
        List<TopicSelect> options = topicSelectService.getOptionsByTid(tid);
        Map<String, Object> result = new HashMap<>();
        result.put("code", 200);
        result.put("message", "成功");
        result.put("data", options);
        return ResponseEntity.ok(result);
    }
}

